<?php

    if ( $news->is_loaded() )
    {
        $admin_link = '';
        if ( $is_logged_in )
        {
            $admin_link = link_to('Edit',
                                  array('controller'=>'admin/news' ,
                                        'action'=>'modify?from_edit=1&id='.$news->get('id')));
        }
        // create the anchor
        $content = $news->get('content');
        if ( strstr($content,'{more}') !== false)
        {
            $content = str_replace('{more}','<a name="read_more" id="read_more"></a>',$content);
        }
        
        // news image
        $news_image = '';
        if ( $news->has_file() )
        {
            use_helper('admin/files');
            $path         = get_installed_path();
            $path_to_file = public_path_to_file($news->get('file_id'));
            // you can use w or h to change dimensions, plus all the other options for phpthumb
            $news_image   = "<img src='$path/img.php?src=$path/$path_to_file&h=100' class='news_image' />";
        }
        
        printf("<div class='news_story'>
                    <h3 class='news_story_title'>%s</h3>
                    %s
                    <div class='news_story_meta'>%s %s</div>
                    <div class='news_story_body'>%s</div> %s
                </div>",
                $news->get('title'),
                $news_image,
                format_date_string($news->get('publish_date')),
                $news->get('source'),
                $content,
                $admin_link);
    } else {
        echo "<p>Sorry, but the request story could not be found.</p>";
    }
?>